<template>
    <div class="app-container helps">
        <el-form v-if="shows">
            <el-form-item label="" prop="electronicAgreement" class="quill-editor">
                <quill-editor v-model="content" ref="text" class="myQuillEditor" :options="editorOption" :disabled="!shows" />
                <!-- <el-input

                    readonly
                    type="textarea"
                    placeholder="请输入内容"
                    rows="10"
                    show-word-limit
                >
                </el-input>-->
            </el-form-item>
        </el-form>
        <div slot="footer" v-if="shows" class="dialog-footer">
            <el-button type="primary" @click="submitForm">确 定</el-button>
        </div>

        <el-input type="textarea" v-if="!shows" disabled placeholder="请输入内容" :rows="15" v-html="content" class="textarea"> </el-input>
    </div>
</template>

<script>
import { listHelp, getHelp, delHelp, addHelp, updateHelp, exportHelp } from '@/api/biz/help';
import { updateHelpcontent } from '@/api/biz/helps';
import { getInfo } from '@/api/login';

export default {
    name: 'Helps',
    data() {
        return {
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 总条数
            total: 0,
            // 【请填写功能名称】表格数据
            helpList: [],
            // 弹出层标题
            title: '',
            // 是否显示弹出层
            open: false,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                helpCenter: undefined,
                aboutUs: undefined,
                electronicAgreement: undefined,
                id: '2'
            },
            editorOption: {
                height: '400px'
            },
            // 表单参数
            form: {},
            // 表单校验
            rules: {},
            //判断权限
            shows: false,
            content: undefined
        };
    },
    created() {
        this.getList();
        getInfo().then(res => {
            if (res.ApplyStatus == 4) {
                this.shows = true;
            }
        });
    },
    methods: {
        /** 查询【请填写功能名称】列表 */
        getList() {
            this.loading = true;
            listHelp(this.queryParams).then(response => {
                this.content = response.rows[0].content;
                this.loading = false;
            });
        },

        /** 提交按钮 */
        submitForm: function() {
            var data = {
                id: 1,
                content: this.content
            };
            updateHelpcontent(data).then(response => {
                if (response.code === 200) {
                    this.msgSuccess('修改成功');
                    this.open = false;
                    this.getList();
                } else {
                    this.msgError(response.msg);
                }
            });
        }
    }
};
</script>
<style>
.helps .textarea {
    width: 100%;
    height: 80vh;
    background: #ffffff;
    box-sizing: border-box;
    border-radius: 4px;
    padding: 20px;
    overflow: auto;
}
</style>
